package cn.pinyuan.news.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.pinyuan.news.bean.NewsUser;
import cn.pinyuan.news.bean.NewsUserExample;
import cn.pinyuan.news.bean.NewsUserExample.Criteria;
import cn.pinyuan.news.mapper.NewsUserMapper;
import cn.pinyuan.news.service.NewsUserService;

@Service
public class NewsUserServiceImpl implements NewsUserService {

	@Autowired
	private NewsUserMapper newsUserMapper;
	
	public NewsUser checkLogin(String username, String password) {
		NewsUserExample example = new NewsUserExample();
		Criteria createCriteria = example.createCriteria();
		createCriteria.andUsernameEqualTo(username);
		NewsUser newsUser = (NewsUser) newsUserMapper.selectByExample(example);
		if(newsUser != null && newsUser.getUserpassword().equals(password)) {
			return newsUser;
		}
		return null;
	}

	public void Regist(NewsUser newsUser) {
		newsUserMapper.insert(newsUser);
	}

}
